home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility2 / resgauge.zip / INIT.C < prev    next >
C/C++ Source or Header  |  1992-08-23  |  4KB  |  145 lines

  1. // ============================================================================
  2. // init.c -- initialization code for ResGauge.
  3. // ============================================================================
  4.  
  5.  
  6. #include <windows.h>
  7. #include "resgauge.h"
  8.  
  9.  
  10. // ============================================================================
  11. // > > > > > > > > > > > > > > >  code  begins  < < < < < < < < < < < < < < < <
  12. // ============================================================================
  13. // Processes the command line.
  14. // ----------------------------------------------------------------------------
  15. void
  16. FAR
  17. PASCAL
  18. ProcessCmdLine(
  19. LPSTR    lpstrCmdLine) // command line
  20. {
  21.     char szTmp[32];
  22.  
  23.     if ( *lpstrCmdLine )
  24.     {
  25.         LoadString(GhInst, IDS_GDI, szTmp, sizeof(szTmp) - 1);
  26.         if ( lstrcmpi(lpstrCmdLine, szTmp) == 0 )
  27.         {
  28.             GcfgCur.wMonitor = MONITOR_GDI;
  29.         }
  30.         else
  31.         {
  32.             LoadString(GhInst, IDS_USER, szTmp, sizeof(szTmp) - 1);
  33.             if ( lstrcmpi(lpstrCmdLine, szTmp) == 0 )
  34.             {
  35.                 GcfgCur.wMonitor = MONITOR_USER;
  36.             }
  37.             else
  38.             {
  39.                 LoadString(GhInst, IDS_BOTH, szTmp, sizeof(szTmp) - 1);
  40.                 if ( lstrcmpi(lpstrCmdLine, szTmp) == 0 )
  41.                     GcfgCur.wMonitor = MONITOR_BOTH;
  42.             }
  43.         }
  44.     }
  45. } // ProcessCmdLine
  46.  
  47.  
  48. // ----------------------------------------------------------------------------
  49. // Initializes the window data and registers the window class.
  50. // ----------------------------------------------------------------------------
  51. BOOL
  52. FAR
  53. PASCAL
  54. InitApplication(
  55. HINSTANCE    hPrevInstance) // previous instance
  56. {
  57.     char     szApp[32];
  58.     BOOL     fReturn;
  59.     WNDCLASS wndclass;
  60.  
  61.     if ( hPrevInstance )
  62.     {
  63.         fReturn = TRUE;
  64.     }
  65.     else
  66.     {
  67.         // load the application name
  68.         LoadString(GhInst, IDS_APPLICATION, szApp, sizeof(szApp) - 1);
  69.  
  70.         // register the main window class
  71.         wndclass.style         = CS_HREDRAW | CS_VREDRAW;
  72.         wndclass.lpfnWndProc   = MainWndProc;
  73.         wndclass.cbClsExtra    = 0;
  74.         wndclass.cbWndExtra    = 0;
  75.         wndclass.hInstance     = GhInst;
  76.         wndclass.hIcon         = NULL;
  77.         wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
  78.         wndclass.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
  79.         wndclass.lpszMenuName  = szApp;
  80.         wndclass.lpszClassName = szApp;
  81.         fReturn = RegisterClass(&wndclass);
  82.     }
  83.  
  84.     return(fReturn);
  85. } // InitApplication
  86.  
  87.  
  88. // ----------------------------------------------------------------------------
  89. // Creates the main window.
  90. // ----------------------------------------------------------------------------
  91. BOOL
  92. FAR
  93. PASCAL
  94. InitInstance(void)
  95. {
  96.     char szApp[32];
  97.     char szError[32];
  98.     BOOL fReturn;
  99.     HWND hWnd;
  100.  
  101.     // assume failure
  102.     fReturn = FALSE;
  103.  
  104.     // load the application name
  105.     LoadString(GhInst, IDS_APPLICATION, szApp, sizeof(szApp) - 1);
  106.  
  107.     // create the main window
  108.     hWnd = CreateWindow(szApp,
  109.                         szApp,
  110.                         WS_OVERLAPPEDWINDOW,
  111.                         CW_USEDEFAULT,
  112.                         CW_USEDEFAULT,
  113.                         CW_USEDEFAULT,
  114.                         CW_USEDEFAULT,
  115.                         0,
  116.                         0,
  117.                         GhInst,
  118.                         NULL);
  119.     if ( hWnd )
  120.     {
  121.         if ( SetTimer(hWnd, TIMER_ID, TIMER_MS, NULL) )
  122.         {
  123.             // normally, we'd call ShowWindow() with nCmdShow, but in this
  124.             // case, we want the app to start up iconic, so we use
  125.             // SW_SHOWMINNOACTIVE
  126.             ShowWindow(hWnd, SW_SHOWMINNOACTIVE);
  127.             UpdateWindow(hWnd);
  128.             fReturn = TRUE;
  129.         }
  130.         else
  131.         {
  132.             // load the error string and tell the user what happened
  133.             LoadString(GhInst, IDS_TIMER_ERROR, szError, sizeof(szError) - 1);
  134.             MessageBox(hWnd, szError, szApp, MB_ICONEXCLAMATION | MB_OK);
  135.         }
  136.     }
  137.  
  138.     return(fReturn);
  139. } // InitInstance
  140.  
  141.  
  142. // =============
  143. // end of init.c
  144. // =============
  145.